import { getMultiLang, toast } from "nc-lightapp-front";
/**
 * 日期区间不能大于多少天的控制
 * @param {*} props 
 * @param {*} areaId 查询区域
 * @param {*} fieldId 字段
 * @param {*} val 字段值
 * @param {*} number 控制天数
 */
export default function (props, areaId, fieldId, val, number) {
    if (val && val.value && val.value.length > 1) {
        var dateS = new Date(val.value[0]);
        var dateE = new Date(val.value[1]);
        if ((dateE - dateS) / (1000 * 60 * 60 * 24) > number) {
            props.search.setSearchValByField(areaId, fieldId, { value: '', display: '' });
            getMultiLang({
                moduleId: 1056, domainName: 'sscrp', currentLocale: 'zh-CN', callback: (json) => {
                    // "1056common-0038": "单据日期范围请限定在30天内"
                    toast({ color: "warning", content: json['1056common-0038'] });
                }
            });
        }
    }
}